<?php
require_once 'common/init.php';
require_once 'config/conf.inc.php';

main();

function main()
{
	global $tpl;
	$err = "";
	
	$product_info = array();
	resolve_postdata($product_info);
	$ret = upload_tmp_image();
	
	$tpl->assign("title", $product_info['cms_title']);
	$tpl->assign("introduction", $product_info['introduction']);
	$tpl->assign("price", $product_info['price']);
	$tpl->assign("original_price", $product_info['original_price']);
	$tpl->assign("discount", sprintf("%0.2f", $product_info['price'] / $product_info['original_price']));
	$tpl->assign("save", $product_info['original_price'] - $product_info['price']);
	$tpl->assign("start_time", $product_info['start_time']);
	$tpl->assign("end_time", $product_info['end_time']);
	$tpl->assign("remain_time", date("H:i:s", $product_info['end_time'] - $product_info['start_time']));
	$tpl->assign("product_desc", stripslashes($product_info['product_desc']));
	$tpl->assign("address", $product_info['address']);
	$tpl->assign("bus", $product_info['bus']);
	$tpl->assign("title_img_name", "upload/".$product_info['title_img_name']);
	
	$ret = $tpl->display('preview.html');
}

function upload_tmp_image()
{
	$img_file = $_FILES['UpLoadImage']["name"];
	$img_tmp_file = $_FILES['UpLoadImage']["tmp_name"];
	$target_path = "/home/horstonema/ntuan_cms/tmp_img";
	$target_file = $target_path."/".$img_file;
	
	if (empty($img_tmp_file))	return;
	
	$ret = move_uploaded_file($img_tmp_file, $target_file);
	return $ret;
}

?>